Appium Essentials by Hans Manoj
Author:Hans, Manoj
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2015-04-08T16:00:00+00:00
We are done with the desired capabilities part; now, we have to initiate the Android Driver to connect with the Appium server, but first we need to import the following packages:
import io.appium.java_client.android.AndroidDriver; import java.net.URL;
Then, initiate the Android Driver:
AndroidDriver driver = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"), caps);
This will launch the app in the Android emulator using the configurations specified in the desired capabilities.
Now, you can use the following class to write the test scripts with TestNG:
import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.remote.MobileCapabilityType; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class TestAppIication { AndroidDriver driver; @BeforeClass public void setUp() throws MalformedURLException{ //Set up desired capabilities DesiredCapabilities caps = new DesiredCapabilities(); File app=new File("path of the apk"); caps.setCapability(MobileCapabilityType.APP,app); caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.4"); caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Android emulator"); caps.setCapability("avd","Name of the AVD to launch"); caps.setCapability(MobileCapabilityType.APP_PACKAGE, "package name of your app (you can get it from apk info app)"); caps.setCapability(MobileCapabilityType.APP_ACTIVITY, "Launch activity of your app (you can get it from apk info app)"); caps.setCapability(MobileCapabilityType.BROWSER_NAME, "Browser");// In case of web apps driver = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"), caps); driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS); } @Test public void testExample(){ //We will put test scripts here } @AfterClass public void tearDown(){ driver.closeApp();//CloseApp() function is used to close the mobile native and hybrid apps while quit() and close() is used for web apps } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12590)
Hello! Python by Anthony Briggs(9926)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9802)
The Mikado Method by Ola Ellnestam Daniel Brolund(9787)
Dependency Injection in .NET by Mark Seemann(9348)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7772)
Grails in Action by Glen Smith Peter Ledbrook(7705)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7566)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7164)
Microservices with Go by Alexander Shuiskov(6933)
Practical Design Patterns for Java Developers by Miroslav Wengner(6850)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6793)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Angular Projects - Third Edition by Aristeidis Bampakos(6209)
The Art of Crafting User Stories by The Art of Crafting User Stories(5722)
NetSuite for Consultants - Second Edition by Peter Ries(5656)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5467)
Kotlin in Action by Dmitry Jemerov(5074)
